<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="<?=gurl('css');?>/admin.css" />
<script language="javascript" src="<?=gurl('js');?>/jq.js"></script>
<script language="javascript" src="<?=gurl('js');?>/common.js"></script>
<style type="text/css">
.textinput {width:400px;}
</style>
</head>
<body>
	<h3 style="background:#E5ECF3; padding:5px; font-size:12px;">> <a href="<?=site_url(rnadminpath().'/main/show/main');?>">首页</a> > <a href="#">发信息</a></h3>
	<div style="margin-top:10px;padding:5px;border:1px solid #9FACB7;">
	<form action="" method="POST" onSubmit="return Validator.Validate(this,2);">
		<ul class="additem" style="width:550px;text-align:right;">
			<li>标题：<input class="textinput" type="text" name="title" id="title" dataType="Require" msg="请输入标题" /></li>
			<li>内容：<textarea style="vertical-align:top;width:400px;height:300px;" name="description" id="description" dataType="Require" msg="请输入内容"></textarea></li>
			<li style="margin-right:150px;">收件人：
				<input type="text" name="keyword" id="keyword" class="searchWord" value="<?=$keyword;?>" />
				<input type="button" value="搜索" class="searchIco" onClick="window.location='<?=gurl(rnadminpath().'/message/post/?');?>keyword='+$('#keyword').val()+'&dosubmit=1'" />
			<br>
			</li>
			<li>
			<select multiple id="select1" style="vertical-align:top;width:180px;height:250px;">  
			<? foreach ($users as $user):?>
				<option value="<?=$user["id"];?>"><?=$user["username"];?></option> 
			<? endforeach;?>
			</select>  
			&nbsp;&nbsp;&nbsp;&nbsp;
			<select multiple id="select2" name="select2" style="vertical-align:top;width:180px;height:250px;">  
			</select>  
			</li>
			<li><a href="javascript:void(0);" id="add">选中添加到右边&gt;&gt;</a><br>
			<a href="javascript:void(0);" id="addAll">全部添加到右边&gt;&gt;</a>
			</li>
			<li style="clear:both;"><input type="button" name="dosubmit" id="dosubmit" value="发送" onClick="sendmsg();">
			<input type="reset" value="重置">
			</li>
		</ul>
	</form>
	</div>
</body>
<script type="text/javascript">  

	//发送信息
	function sendmsg()
	{
		//获取用户
		var count=$("#select2 option").length; 
		var users = "";
		for(var i=0;i<count;i++) 
	    {    
	    	users += "," + $("#select2 ").get(0).options[i].value;
	    } 
	    var title = $("#title").val();
	    var description = $("#description").val();
	    if(title == "") {
	    	alert("请输入标题");
	    	return false;
	    } else if(description == "") {
	    	alert("请输入内容");
	    	return false;
	    } else if(users == "") {
	    	alert("请选择收件人");
	    	return false;
	    }
	    $.ajax({
			type:"POST",
			url:"/mrfengnimda/message/dopost/",
			data:"users="+users+"&title="+title+"&description="+description,
			success:function(data){
				window.location.href=data;
			}
		});
	}
	
   $(document).ready(function(){  
	   $('#add').click(function(){  
		   var $options = $('#select1 option:selected');//获取当前选中的项  
		   var $remove = $options.remove();//删除下拉列表中选中的项  
		   $remove.appendTo('#select2');//追加给对方  
	   });  
	  $('#addAll').click(function(){  
		  var $options = $('#select1 option');  
		  $options.appendTo('#select2');  
	  });  	         
	  //双击事件  
	  $('#select1').dblclick(function(){   
		  var $options = $('option:selected', this);//注意此处“option”与“:”之间的空格，有空格是不可以的  
		  $options.appendTo('#select2');  
	  });  	         
	  $('#select2').dblclick(function(){  
		  $('#select2 option:selected').appendTo('#select1');  
	  });     
  });  
</script>  
</html>
